package com.tanhua.manage.controller;

import com.tanhua.manage.service.UserManageServiceXun;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * xun
 */
@RestController
@RequestMapping("manage/users")
public class UserManageControllerXun {

    @Autowired
    private UserManageServiceXun userManageServiceXun;






    /**
     * 用户冻结操作
     * @param param
     * @return
     */
    @PostMapping("freeze")
    public String userFreeze(@RequestBody Map<String,String> param){
        try {
            Integer userId = Integer.parseInt(param.get("userId"));
            Integer freezingTime = Integer.parseInt(param.get("freezingTime"));
            Integer freezingRange =Integer.parseInt(param.get("freezingRange"));
            String reasonsForFreezing = param.get("reasonsForFreezing");
            String frozenRemarks = param.get("frozenRemarks");

            String message=this.userManageServiceXun.userFreeze(userId,freezingTime,freezingRange,reasonsForFreezing,frozenRemarks);
            return message;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "操作失败";
    }


    /**
     * 用户解冻操作
     * @param param
     * @return
     */
    @PostMapping("unfreeze")
    public String userUnFreeze(@RequestBody Map<String,String> param){
        try {
            Integer userId = Integer.parseInt(param.get("userId"));
            String reasonsForThawing = param.get("reasonsForThawing");
            String message=this.userManageServiceXun.userUnFreeze(userId,reasonsForThawing);
            return message;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "操作失败";
    }
}
